#pragma once
#include <Rz/Types.h>

namespace Rz {

class ReferenceCounter 
{
	public:
		RZ_INLINE void Ref() const
		{
			++_referenceCount;
		}

		RZ_INLINE void Unref() const
		{
			if ((--_referenceCount) <= 0)
			{
				delete this;
			}
		}

		RZ_INLINE u32 GetRefCount() const
		{
			return _referenceCount;
		}

	protected:
		RZ_INLINE ReferenceCounter()
			: _referenceCount(0)
		{

		}

		RZ_INLINE virtual ~ReferenceCounter()
		{
		
		}

	private:
		mutable s32 _referenceCount;
};

}
